<template>
<view>
<view v-for="(item, index) in goodsList" :key="index">
  <navigator url="../rushdetails/rushdetails">
    <view class="groupbook">
      <view class="group-photo fl">
        <view class="photo-warp">
          <image :src="item.icom"></image>
          <view class="mask">
            剩余
            <text>{{item.stockNum}}</text> 件
          </view>
        </view>
      </view>
      <view class="group-right fr">
        <view class="right-title">
          <text>{{item.name}}</text>
        </view>
        <view class="fl">
          <view class="right-price">
            <text>￥</text>
            <text>{{item.flashPrice}}</text>
          </view>
          <view class="del original-price">
            <text>￥</text>
            <text>{{item.sellingPrice}}</text>
          </view>
        </view>
        <navigator>
          <view class="purchase-btn">
            <text>立即抢购</text>
          </view>
        </navigator>
      </view>
    </view>
  </navigator>
</view>
</view>
</template>

<script>
// var util = require('../../utils/util.js');
// import request from '../../utils/requestUtils.js';
// import {
//   xcxId,
//   flashGoods_url,
// } from "../../utils/data.js";
var app = getApp();

export default {
  data() {
    return {
      page: 1,
      pageSize: 15,
      hasMoreData: true,
      contentlist: [],
      goodsList: ""
    };
  },

  components: {},
  props: {},

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getIndex();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {},

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {},

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {},

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {},

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {},

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {},

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {},
  methods: {
    //获取首页内容
    getIndex: function () {
      var openId = wx.getStorageSync("openid");
      var $this = this;
      var params = {};
      request.POST({
        url: flashGoods_url,
        params: params,
        header: request.postHeader,
        success: function (res) {
          //console.log(res)
          var resultData = res.data.data; //console.log(resultData.goodsList)
          // if (!res.data.success) {
          //   return;
          // }

          $this.setData({
            goodsList: resultData.goodsList,
            page: resultData.page
          });
        },
        fail: function (res) {//失败后的逻辑
        }
      });
    }
  }
};
</script>
<style>
@import "./purchase.css";
</style>